/*
    班级管理
*/
const { model, Sequelize } = require('../../core/model.js');

const answersModel = model.define('answers', {
    paper_id: {
        type: Sequelize.INTEGER,
        validate: {
            notEmpty: true
        }
    },
    content: {
        type: Sequelize.TEXT,
        validate: {
            notEmpty: true
        },
        get(val) {
            const content = this.getDataValue('content')
            if (content) {
                return JSON.parse(this.getDataValue('content'));
            }
        }
    },
    item: {
        type: Sequelize.TEXT,
        validate: {
            notEmpty: true
        },
        get() {
            const content = this.getDataValue('item')
            if (content) {
                return JSON.parse(this.getDataValue('item'));
            }
        }
    },
    note: {
        type: Sequelize.TEXT,
    },
    ctime: Sequelize.DATE,
    mtime: Sequelize.DATE,
}, {
        createdAt: 'ctime',
        updatedAt: 'mtime',
    })
answersModel.sync({
    // force: true
})
module.exports = {
    answersModel,
    model,
    Op: Sequelize.Op
};
